<p>A selection created with setBaseAndExtent should be directional</p>
<div id="div" contenteditable="true">There should be four characters selected in this sentence.</div>
<ul id="console"></ul>
<script>
function log(str) {
  document.getElementById("console").innerHTML += str + "<br>";
}

if (window.testRunner) {
    testRunner.dumpAsText();

    var text = document.getElementById("div").firstChild;
    var selection = window.getSelection();

    selection.collapse(text, 0);
    selection.modify("move", "forward", "character");
    
    selection.setBaseAndExtent(text, 5 + 7, text, 5);
    // Extending this 5 character selection will select 6 characters.
    testRunner.execCommand("MoveForwardAndModifySelection");
    var selectedText = selection.toString();
    var expectedText = "should";
    if (selectedText != expectedText)
        log("Failure: Selected text was \"" + selectedText + "\" and should be \"" + expectedText + "\"");
    else
        log("Success");
} else
    log("Failure: This test cannot be run manually.")
</script>
